package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.dao.SetMealDao;
import com.itheima.health.dto.SetmealDto;
import com.itheima.health.entity.Result;
import com.itheima.health.service.MemberService;
import com.itheima.health.service.OrderService;
import com.itheima.health.service.ReportService;
import com.itheima.health.service.SetMealService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 数据报告控制器
 */
@RestController
@RequestMapping("/report")
@Slf4j
@Api(tags = "数据报告展示接口")
public class ReportController {

    @Autowired
    private SetMealService setMealService;


    //饼状图的插入
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport(){
        ArrayList<SetmealDto> setmealCount = setMealService.getnamesandshu();
        Set<String> setmealNames = setMealService.getnames();
        HashMap<String, Object> data = new HashMap<>();
        data.put("setmealCount",setmealCount);
        data.put("setmealNames",setmealNames);
        return new Result(true, MessageConst.PIC_UPLOAD_SUCCESS,data);
    }

    //线形图的数据插入
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        HashMap<String, Object> months = setMealService.getyuefen();
        return new Result(true, MessageConst.PIC_UPLOAD_SUCCESS,months);
    }
}
